<?php
    @header("Content-Type:text/html;charset=utf-8");

    //简写  
    const HOST = "localhost:3306";
    const USER = "root";
    const PASSWORD = "root";
    const DBNAME = "2111";

    $conn = mysqli_connect(HOST,USER,PASSWORD,DBNAME);  

    if(!$conn){
        exit("数据库链接失败");
    }

    // 转码设置   兼容低版本
    mysqli_query($conn,"set names utf8"); // 从数据库取数据时  将编码转为utf-8;  
    mysqli_query($conn,"set character set utf-8"); // 向数据库存数据时  将编码转为utf-8

?>